package com.strange.mdl.module.mdl.service.index;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.strange.mdl.framework.common.pojo.PageResult;
import com.strange.mdl.framework.common.util.object.BeanUtils;
import com.strange.mdl.module.mdl.controller.admin.activity.vo.ActivityPageReqVO;
import com.strange.mdl.module.mdl.controller.admin.dailydharma.vo.AppDailydharmaRespVO;
import com.strange.mdl.module.mdl.controller.admin.dailydharma.vo.DailydharmaPageReqVO;
import com.strange.mdl.module.mdl.controller.admin.dailydharma.vo.DailydharmaRespVO;
import com.strange.mdl.module.mdl.controller.admin.debatehall.vo.AppDebatehallRespVO;
import com.strange.mdl.module.mdl.controller.app.activity.vo.AppActivityRespVO;
import com.strange.mdl.module.mdl.controller.app.index.vo.AppIndexRespVO;
import com.strange.mdl.module.mdl.dal.dataobject.activity.ActivityDO;
import com.strange.mdl.module.mdl.dal.dataobject.dailydharma.DailydharmaDO;
import com.strange.mdl.module.mdl.dal.dataobject.debatehall.DebatehallDO;
import com.strange.mdl.module.mdl.dal.dataobject.debatehall.DebatehallUserDO;
import com.strange.mdl.module.mdl.dal.dataobject.debatehallcomment.DebatehallCommentDO;
import com.strange.mdl.module.mdl.dal.dataobject.sutras.MdlSutrasDO;
import com.strange.mdl.module.mdl.dal.mysql.activity.ActivityMapper;
import com.strange.mdl.module.mdl.dal.mysql.dailydharma.DailydharmaMapper;
import com.strange.mdl.module.mdl.dal.mysql.debatehall.DebatehallMapper;
import com.strange.mdl.module.mdl.dal.mysql.sutras.MdlSutrasMapper;
import com.strange.mdl.module.mdl.service.dailydharma.DailydharmaService;
import jakarta.annotation.Resource;
import org.springframework.stereotype.Service;
import org.springframework.validation.annotation.Validated;

import java.util.List;

import static com.strange.mdl.framework.common.exception.util.ServiceExceptionUtil.exception;

/**
 * 活动 Service 实现类
 *
 * @author 密谛灵总控
 */
@Service
@Validated
public class IndexServiceImpl implements IndexService {

    @Resource
    private DailydharmaMapper dailydharmaMapper;

    @Resource
    private DebatehallMapper debatehallMapper;

    @Resource
    private ActivityMapper activityMapper;

    @Resource
    private MdlSutrasMapper mdlSutrasMapper;

    @Resource
    private DailydharmaService dailydharmaService;


    @Override
    public List<String> getBanner() {
        return List.of("https://scripture.oss-cn-shenzhen.aliyuncs.com/20250626/5127eb066782482059a267ad80a6921e_1750902568875.jpg");
    }

    @Override
    public AppIndexRespVO getAppIndex() {
        AppIndexRespVO appIndexRespVO = new AppIndexRespVO();
        // 首屏banner
        appIndexRespVO.setBannerList(getBanner());
        // 近期弘法视频
        List<DailydharmaDO> dailydharmaDOS = dailydharmaMapper.lastDailydharmaTwo();
        appIndexRespVO.setDailydharmaList(BeanUtils.toBean(dailydharmaDOS, AppDailydharmaRespVO.class));

        // 近期辩经
        List<DebatehallDO> debatehallDOS = debatehallMapper.lastDailydharmaTwo();
        appIndexRespVO.setDebatehallList(BeanUtils.toBean(debatehallDOS, AppDebatehallRespVO.class));
        // 经书
        LambdaQueryWrapper<MdlSutrasDO> wrapper = new LambdaQueryWrapper<>();
        wrapper.orderByDesc(MdlSutrasDO::getCreateTime)
                .last("LIMIT 3");
        List<MdlSutrasDO> sutrasList = mdlSutrasMapper.selectList(wrapper);
        appIndexRespVO.setSutrasList(sutrasList);

        // 近期法会

        List<ActivityDO> activityDOS = activityMapper.lastActivityTwo();
        appIndexRespVO.setActivityList(BeanUtils.toBean(activityDOS, AppActivityRespVO.class));


        return appIndexRespVO;

    }
}